﻿Imports Models.Users

Namespace Security

    Public Class RolVO
        Inherits BaseVO

        Private _rolId As Integer
        Private _code As String
        Private _name As String
        Private _companyId As Integer

        Private _company As CompanyVO
        Private _processes As New Generic.List(Of ProcessVO)

        Sub New()
        End Sub

        Sub New(entity As Data.BaseModel.Rol, Optional skipRelations As Boolean = False)
            rolId = entity.RolId
            code = entity.Code
            name = entity.Name

            companyId = entity.CompanyId

            If entity.Company IsNot Nothing Then
                company = New CompanyVO(entity.Company)
            End If

            If Not skipRelations Then
                If entity.Processes IsNot Nothing Then
                    For Each oItem As Data.BaseModel.Process In entity.Processes
                        processes.Add(New ProcessVO(oItem))
                    Next
                End If
            End If

        End Sub

        <StringLengthAtt(50, "code", 3)> _
        Public Property code As String
            Get
                Return _code
            End Get
            Set(value As String)
                _code = value
            End Set
        End Property

        <RequiredAtt("name")> _
        Public Property name As String
            Get
                Return _name
            End Get
            Set(value As String)
                _name = value
            End Set
        End Property

        Public Property rolId() As Integer
            Get
                Return _rolId
            End Get
            Set(ByVal value As Integer)
                _rolId = value
            End Set
        End Property

        Public Property companyId() As Integer
            Get
                Return _companyId
            End Get
            Set(ByVal value As Integer)
                _companyId = value
            End Set
        End Property

        Public Property company() As CompanyVO
            Get
                Return _company
            End Get
            Set(ByVal value As CompanyVO)
                _company = value
            End Set
        End Property

        Public Property processes() As Generic.List(Of ProcessVO)
            Get
                Return _processes
            End Get
            Set(ByVal value As Generic.List(Of ProcessVO))
                _processes = value
            End Set
        End Property

    End Class

End Namespace